# 对序列做切片操作

my_list = [0, 1, 2, 3, 4]
result1 = my_list[1:4]
print(f"结果1: {result1}")

my_tuple = (0, 1, 2, 3, 4, 5, 6)
result2 = my_tuple[:]
print(f"结果: {result2}")

my_str = "01234567"
result3 = my_str[::2]
print(f"结果3: {result3}")

# 对str进行切片，从头开始，到最后结束，步长-1
my_str = "0123456"
result4 = my_str[::-1] # 等同于将序列反转
print(f"结果4: {result4}")

# 对列表进行切片，从3下标位置开始，到1下标位置结束，步长-1（反向切片）
my_list = [0, 1, 2, 3, 4, 5, 6]
result5 = my_list[3:1:-1]
print(f"结果5是: {result5}")

my_tuple = (0, 1, 2, 3, 4, 5, 6)
result6 = my_tuple[::-2]
print(f"结果6: {result6}")
